package com.xinzhitong.www.service.impl;

import com.xinzhitong.www.exception.news.NewsIsNullException;
import com.xinzhitong.www.mapper.NewsMapper;
import com.xinzhitong.www.pojo.News;
import com.xinzhitong.www.service.NewsService;
import com.xinzhitong.www.utils.FileHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 新闻服务实现
 *
 * @author 魏骆淳
 */
@Service
@Transactional
public class NewsServiceImpl implements NewsService {

    @Resource
    private NewsMapper newsMapper;

    @Override
    public Map<String, Object> selectNewsUrl(Integer newsId) throws NewsIsNullException {
        News newsUrl = newsMapper.selectNewsUrl(newsId);
        if (newsUrl == null) {
            throw new NewsIsNullException();
        } else {
            Map<String, Object> map = new HashMap<>();
            map.put("newsUrl", newsUrl.getText());
            return map;
        }
    }
}
